package cloud.maque.auth.exceptions;

import cloud.maque.common.core.response.R;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class UserGlobalExceptionHandler {


    @ExceptionHandler(UserInfoException.class)
    public R handleUserInfoException(UserInfoException e) {
        return R.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "用户名或密码不能为空");
    }

    @ExceptionHandler(UserDisabledException.class)
    public R handleUserDisabledException(UserDisabledException e) {
        return R.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "用户已被禁用");
    }

    @ExceptionHandler(UserNotExistsException.class)
    public R handleUserNotExistsException(UserNotExistsException e) {
        return R.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "用户不存在");
    }

    @ExceptionHandler(UserPasswordErrorException.class)
    public R handleUserPasswordErrorException(UserPasswordErrorException e) {
        return R.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "密码不正确");
    }
}
